// vm.hpp
// The core of the ripe virtual machine.
//
// Copyright (C) 2008  Maksim Sipos <msipos@mailc.net>
//
// This file is a part of the Ripe language project.
//
// Ripe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef R_VM_HPP
#define R_VM_HPP

#include <istream>
#include "adts/intern.hpp"
#include "adts/map.hpp"

namespace Ripe {
  // Generic VM error
  class ErrorVM : public Exception {
  };
  
  // VM File load error
  class ErrorVMFileLoad : public Exception {
  };

  // An instance of the VM
  class VM {
    public:
      VM();
      
      // Load a VM file.
      void load(std::istream* s);

    private:
      // Symbol internment table.
      Intern intern;

      // Symbol string to symbol # map
      Map<char*, uint32_t> str_to_symbol;
      
      // Symbol # map to symbol string map (symbol lookup)
      Map<uint32_t, char*> symbol_to_str;
  };
}

#endif // R_VM_HPP
